home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / com / internet / sting / time / t_random / t_random.s < prev   
Text File  |  1997-08-09  |  6KB  |  199 lines

  1. ;----------------------------------------------------------------------------
  2. ;File name:    T_RANDOM.S            Revision date:    1997.08.10
  3. ;Creator:    Ulf Ronald Andersson        Creation date:    1997.08.01
  4. ;(c)1996 by:    Ulf Ronald Andersson        All rights reserved
  5. ;----------------------------------------------------------------------------
  6. ;Purpose:    Randomizes the system time setting, to allow repeated
  7. ;        testing of time server clients that can correct this.
  8. ;----------------------------------------------------------------------------
  9. ;Required header declarations:
  10. ;
  11.     .include    "uran\STRUCT.SH"    ;PASM adapted structures
  12.     .include    "uran\URAn_SYS.SH"    ;Main system definitions
  13.     .include    "uran\URAn_LA.SH"    ;Line A variables etc
  14.     .include    "uran\URAn_DOS.SH"    ;GEMDOS, BIOS, XBIOS
  15.     .include    "uran\URAn_GEM.SH"    ;VDI & AES
  16.     .include    "uran\URAn_APP.SH"    ;General application support
  17.     .include    "uran\URAn_AV.SH"    ;AV/VA protocol + MP protocol
  18. ;
  19.     .include    "sting\NET_TCON.SH"    ;handles time conversions
  20. ;
  21. ;----------------------------------------------------------------------------
  22. ;
  23. exec_message        = 1
  24. ;
  25. ;----------------------------------------------------------------------------
  26. ;
  27.     .text
  28. ;
  29.     start_app
  30. ;
  31. ;----------------------------------------------------------------------------
  32. ;
  33.     .data
  34. ;
  35. acc_name:
  36.     dc.b    '  Time Randomizer',NUL    ;for ACC menu registration
  37.     dc.b    NUL
  38.     even
  39. ;
  40. id_app_name_s:
  41.     dc.b    'T_RANDOM',NUL
  42.     even
  43. ;
  44. ;----------------------------------------------------------------------------
  45. ;
  46.     .bss
  47. ;
  48. message:    ds.w    8        ;evnt_mesag message pipe
  49. intin:        ds.w    30        ;30 words or more for AES/VDI
  50. intout:        ds.w    45        ;45 words or more for AES/VDI
  51. ptsin:        ds.w    30        ;30 words or more for VDI
  52. ptsout:        ds.w    12        ;12 words or more for VDI output coordinates
  53.         ds.l    200        ;subroutine stack >= 100 longs
  54. mystack:    ds.l    1        ;top of subroutine stack
  55. ;
  56. ;----------------------------------------------------------------------------
  57. ;
  58.     .text
  59. ;
  60. ;----------------------------------------------------------------------------
  61. ;Start of:    init_app
  62. ;----------------------------------------------------------------------------
  63. ;
  64. init_app:
  65.     rts
  66. ;
  67. ;----------------------------------------------------------------------------
  68. ;End of:    init_app
  69. ;----------------------------------------------------------------------------
  70. ;Start of:    exec_app
  71. ;----------------------------------------------------------------------------
  72. ;
  73. exec_app:
  74.     xbios        Random        ;get one 24 bit random number, but it
  75.     add.l        d0,rand_seed    ;isn't very good, so only used as seed
  76.     bsr        rand_long    ;this gives a very random longword
  77.     lea        tcon_data(pc),a0
  78.     move.l        d0,tcon_net_time(a0)    ;simulate random network time
  79.     tcon_net2man    ;convert 32 bit number to human (separate) time format
  80.     tcon_man2tos    ;convert to TOS format (2 bitpacked words)
  81.     tcon_tos2real    ;set system time to the resulting (random) time & date
  82. exit_terminate:
  83.     clr.l    d0
  84.     rts
  85. ;
  86. ;----------------------------------------------------------------------------
  87. ;End of:    exec_app
  88. ;----------------------------------------------------------------------------
  89. ;Start of:    exec_mesag
  90. ;----------------------------------------------------------------------------
  91. ;
  92.     .ifne        exec_message
  93. exec_mesag:
  94.     cmp        #AC_CLOSE,message
  95.     bne.s        .not_AC_CLOSE
  96.     sf        keep_wind_f
  97.     bra        exit_exec_mesag
  98. ;
  99. .not_AC_CLOSE:
  100.     cmp        #AP_TERM,message
  101.     bne.s        .not_AP_TERM
  102.     tst.l        d7
  103.     bmi        exit_exec_mesag        ;AP_TERM is not for ACCs
  104.     clr.l        d0            ;flag no error
  105.     bra        exit_terminate
  106. ;
  107. .not_AP_TERM:
  108.     cmp        #VA_START,message
  109.     bne.s        .not_VA_START
  110.     st        VA_START_f
  111.     move        message+2,AV_partner_id
  112.     move.l        message+6,VA_START_cmd_p
  113.     AV_send        PROTOKOLL,#w_VA_START+w_AV_STARTED_A,id_app_name_s
  114. ;
  115. ;Add ALL handling of the passed command line here, if you need to do some later
  116. ;you must copy it here, because the original may disappear after AV_STARTED.
  117. ;
  118.     AV_send.i    STARTED,VA_START_cmd_p
  119.     bra        exec_app
  120. ;
  121. .not_VA_START:
  122.     cmp        #VA_PROTOSTATUS,message
  123.     bne.s        .not_VA_PROTOSTATUS
  124.     move        message+8,VA_protostatus
  125.     move        message+6,VA_protostatus+2
  126.     bra        exit_exec_mesag
  127. ;
  128. .not_VA_PROTOSTATUS:
  129. exec_mesag_extend:
  130. ;
  131. ;Add client/server dependent message event work here
  132. ;
  133. exit_exec_mesag:
  134.     rts
  135.     .endif        exec_message
  136. ;
  137. ;----------------------------------------------------------------------------
  138. ;End of:    exec_mesag
  139. ;----------------------------------------------------------------------------
  140. ;
  141. rand_long:
  142.     move.l    rand_seed(pc),d0
  143.     bne.s    .seed_ok
  144.     move.l    #'Rand',d0
  145. .seed_ok:
  146.     bsr.s    rand_31_long
  147.     move.l    d0,rand_seed
  148.     rts
  149. ;
  150. rand_seed:
  151.     dc.l    'Rand'
  152. ;
  153. ;----------------------------------------------------------------------------
  154. ;
  155. rand_31_long:    ;generates 32 entirely new bits from older value
  156.     lsr.l    #1,d0        ;Adjust 31-bit pseudorandom shifter
  157.     move.l    d0,d1        ;copy to d1
  158.     ror.l    #3,d1        ;shift d1 by 3 bits for 31 bit pseudorandomicity
  159.     eor.w    d1,d0        ;generate 16 new pseudorandom top bits 
  160.     swap    d0        ;align 16 new bits correctly
  161.     roxl.w    #1,d0        ;align 15 old bits correctly and get dummy bit 0
  162. rand_31_word:    ;generates 16 entirely new bits from older value
  163.     lsr.l    #1,d0        ;Adjust 31-bit pseudorandom shifter
  164.     move.l    d0,d1        ;copy to d1
  165.     ror.l    #3,d1        ;shift d1 by 3 bits for 31 bit pseudorandomicity
  166.     eor.w    d1,d0        ;generate 16 new pseudorandom top bits 
  167.     swap    d0        ;align 16 new bits correctly
  168.     roxl.w    #1,d0        ;align 15 old bits correctly and get dummy bit 0
  169.     rts
  170. ;
  171. ;----------------------------------------------------------------------------
  172. ;
  173.     make    GEM_links
  174.     make    TCON_links
  175.     make    AV_links
  176. ;
  177. ;----------------------------------------------------------------------------
  178. ;
  179. text_limit:    .data
  180. ;
  181. ;----------------------------------------------------------------------------
  182. ;
  183. ;----------------------------------------------------------------------------
  184. ;
  185. data_limit:    .bss
  186. ;
  187. ;----------------------------------------------------------------------------
  188. ;
  189. tcon_data:    ds.b    sizeof_tcon
  190. VA_START_f:    ds.w    1
  191. VA_START_cmd_p:    ds.l    1
  192. VA_protostatus:    ds.l    1
  193. ;
  194. ;----------------------------------------------------------------------------
  195. bss_limit:    .end
  196. ;----------------------------------------------------------------------------
  197. ;End of file:    T_RANDOM.S
  198. ;----------------------------------------------------------------------------
  199.